package itheima;

import java.util.Scanner;

public class Binary {
    public static void main(String[] args) {
        /*Scanner sc = new Scanner(System.in);
        System.out.print("请输入一个十进制数字：");
        int num = sc.nextInt();

        String result = toBinary(num);
        System.out.println("十进制转化为二进制是：" + result);*/

        // 1.(1)计算1+2+...+99的值
        /*int temp = 0 ;
        for (int i = 1; i < 100 ; i++) {
            temp += i;
        }
        System.out.println(temp);
    }*/

        // 1.(2)计算1+3+5+...+99的值
        /*int temp = 0 ;
        for (int i = 1; i < 100 ; i++) {
            if(i % 2 != 0) {
                temp += i;
            }
        }
        System.out.println(temp);
    }*/

        // 2.使用do...while循环语句计算正数5的阶乘
        System.out.println("请输入一个整数用于计算该数的阶乘");
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        int temp = 1;
        int result = 1 ;
        do{
           result *= temp;
           temp++;
        }while(temp <= number);
        System.out.println("该数的阶乘是：" + result);
    }



    /*public static String *//*int*//* toBinary(int num) {
        String result = "";
//        int result = 0;
        while (num != 0) {
            int ge = num % 2;
            result = ge + result;
            num = num / 2;
        }
        return result;
    }*/
}
